<?php


namespace app\common\Cache;


use app\admin\model\SysConfig;
use app\common\CacheKey;

class SystemConfigCache
{
    public static function getConfig($name)
    {
        $key = sprintf(CacheKey::SYSTEM_CONFIG, $name);
        $config = redis()->get($key);
        if (empty($config) || $config == 'null') {
            $config = SysConfig::getInstance()->getValues(['name' => $name, 'status' => 0]);
            redis(2)->set($key, $config, 86400);
        }
        return $config;
    }

    public static function delConfigCache($name)
    {
        $key = sprintf(CacheKey::SYSTEM_CONFIG, $name);
        redis(2)->del($key);
    }
}